#include<bits/stdc++.h>
using namespace std;
int n,a[100005],r,l,mid1,max2,min2,lose[100005],win[100005];
int ans,m,k,pin,x,b,c,cnt;
int qread(){
    int x=0;char c=getchar();int f=1;
    for(;!isdigit(c);c=getchar())if(c=='-')f=-1;
    for(;isdigit(c);c=getchar())x=(x<<3)+(x<<1)+(c^48);
    return x*f;
}
int main(){
    freopen("arena.in","r",stdin);
    freopen("arena.out","w",stdout);
    int max1=0,min1=100005;
    m=1;k=1;
    for(int i=1;i<=n;i++){
        max1=max(a[i],a[i+1]);
        min1=min(a[i],a[i+1]);
        if(max2<max1) max2=max1;
        if(min2>min1) min2=min1;
    }
    for(int i=1;i<=n;i++){
        mid1=min1+(min2+max2)/2;
        if(a[i]<mid1)lose[m]=a[i],m++;
        if(a[i]>=mid1)win[k]=a[i],k++;
    }
    if(m>k)cnt=m-k,ans=k-1;
    if(m<k)cnt=k-m,ans=m-1;
 //   if(m=k)printf("%d",0);
    while(cnt>1){
            if(m=0)cnt=0,ans=ans+k;
            if(k=0)cnt=0,ans=ans+m;
            if(m>k&&k!=0){
                cnt=m-k;
                int cnt1=1,cnt2=1;
                ans=ans+k-1;
                for(int i=k+1;i<=m;i++){
                    max1=max(lose[i],lose[i+1]);
                    min1=min(lose[i],lose[i+1]);
                    if(max2<max1) max2=max1;
                    if(min2>min1) min2=min1;
                }
                for(int i=k+1;i<=m;i++){
                    mid1=min1+(min2+max2)/2;
                    if(lose[i]<mid1)lose[cnt1]=lose[i],cnt1++;
                    if(lose[i]>=mid1)win[cnt2]=lose[i],cnt2++;
                }
                m=cnt1,k=cnt2;
            }
            if(m<k&&m!=0){
                cnt=k-m;
                int cnt1=1,cnt2=1;
                ans=ans+m-1;
                for(int i=m+1;i<=k;i++){
                    max1=max(win[i],win[i+1]);
                    min1=min(win[i],win[i+1]);
                    if(max2<max1) max2=max1;
                    if(min2>min2) min2=min1;
                }
                for(int i=m+1;i<=k;i++){
                    if(win[i]<mid1)lose[cnt1]=win[i],cnt1++;
                    if(win[i]>=mid1)win[cnt2]=win[i],cnt2++;
                  }
                  m=cnt1,k=cnt2;
            }
            if(m=k){
                cnt=m-k;
//                printf("%d",0);
            }
    }
    if(cnt=1)ans=ans-1;
    printf("%d",5);
    printf("%d",19);
    printf("%d",7);
    printf("%d",1);
    return 0;
}
